



public class ConditionalAndExpr extends Expression {

	EqualityExpr eqExpr;
	ConditionalAndExpr condExpr;
	int op = Type.LA;

	public ConditionalAndExpr() {

	}

	public ConditionalAndExpr(EqualityExpr eqExpr, ConditionalAndExpr condExpr) {
		super();
		this.eqExpr = eqExpr;
		this.condExpr = condExpr;
	}

	public void check() throws SemanticException {
		eqExpr.check();
		if (condExpr != null)
			condExpr.check();
		checkType();
	}

	public int checkType() throws SemanticException {
		if (condExpr != null) {
			// check for boolean type
			if (condExpr.checkType() != Type.BL
					|| eqExpr.checkType() != Type.BL)
				throw new SemanticException(
						"Conditional expression must be on boolean");
			return Type.BL;
		}

		return eqExpr.checkType();
	}

	public String toString() {
		String ret = "ConditionalAndExpr\n";
		String s = "";
		s += eqExpr.toString();
		for (String st : s.split("\n"))
			ret += "| " + st + "\n";
		return ret;
	}
}
